<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/views/global/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath %>">
<%@include file="/views/global/ShopInclude.jsp" %>
<link rel="stylesheet" type="text/css" href="static/css/page/index.css" />
<link href="static/css/page/shops.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="static/javascript/jquery.min.js"></script>
<title>${pageTitle }</title>
</head>
<body>
<%@include file="/views/global/SearchBar.jsp" %>

<!-- INDEPENDENT BRAND内容开始 -->
<div class="independentBrandContent font">
  <%@include file="/views/global/ShopLeftMenu.jsp" %>
  
  <div class="brandContentRight">    
    <!-- brand结果排序选项 start -->
    <div style="overflow: hidden;zoom: 1;height: 35px;">
    <ul class="brandContentSort">
    	<c:choose>
			<c:when test="${'gmtModified' eq searchVo.orderBy }">
				<li class="${searchVo.order }">最新 NEW<span class="active" value="gmtModified"></span></li>
			</c:when><c:otherwise>
				<li class="desc">最新 NEW<span value="gmtModified"></span></li>
			</c:otherwise>
		</c:choose>
		<c:choose>
			<c:when test="${'likeNum' eq searchVo.orderBy }">
				<li class="${searchVo.order }">最热 HOT<span class="active" value="likeNum"></span></li>
			</c:when><c:otherwise>
				<li class="desc">最热 HOT<span value="likeNum"></span></li>
			</c:otherwise>
		</c:choose>
	</ul>
    <!-- brand结果排序选项 end -->
    <!-- brand页码 -->
	<form id="submitForm" name="submitForm" action="${actionPath }" method="post">
		<input type="hidden" name="pageIndex" value="1"/>
		<input type="hidden" name="sellerType" value="${searchVo.sellerType }"/>
		<input type="hidden" name="keyword" value="${searchVo.keyword }"/>
		<input type="hidden" name="categoryIdPath" value="${searchVo.categoryIdPath }"/>
		<input type="hidden" name="countryId" value="${searchVo.countryId }"/>
		<input type="hidden" name="orderBy" value="${searchVo.orderBy }"/>
		<input type="hidden" name="order" value="${searchVo.order }"/>
	</form>
	<div class="pagination-simple  shopPagination">
		<pagination:pagenav pageInfo="${pageInfo }" url="${actionPath }" formName="submitForm" gotoFunction="switchPage" className="pagination-prev"></pagination:pagenav>
	</div>
	</div>
      <!-- brand页码 结束 -->
      <div class="brandContentList">
       <ul>
        <c:forEach var="designer" items="${entityList }" varStatus="status">
        <c:if test="${status.count%4!=0}">
        <li class="brandItem">
        <div class="showpicarea" id="seller_${designer.userId }">
        	<div class="item-gallery">
        	</div>
            <div class="fourpic-text">${designer.favorite }</div>
        </div>
        	<a href="seller/sellerHome?sellerId=${designer.userId }" title="CLICK HERE TO SEE HER HOME PAGE" target="_blank">
				<c:choose>
	            <c:when test="${empty designer.sellerFileId }">
	            <img class="independentBrandPortrait" src="static/images/global/blank.png" />
	            </c:when><c:otherwise>
	            <img class="independentBrandPortrait" src="${fileServerBasePath }image/resize/${designer.sellerFileId }?width=170&height=170" />
	            </c:otherwise></c:choose>
			</a>
          <div class="independentShopName">${mfn:upperCase(designer.storeName) } &nbsp;&nbsp;<span>${designer.countryName }</span></div>
          <div class="brandItemsCount">
              <span class="left">${designer.itemCount }</span>
              <p class="left">ITEMS 商品</p>
          </div>
          <div><a href="javascript:void(0)" onclick="shopFavorite(this,'${designer.userId}')" class="brandFavoriteBtn ${designer.userId}"></a></div>
          <div><a href="javascript:void(0)" onclick="showShopLastItems(this,'${designer.userId}')" class="brandAddBtn"></a></div>
        </li>
        </c:if>
        <c:if test="${status.count%4==0}">
        <li class="brandItem">
        <div class="showpicarea" style="margin-left:-250px;" id="seller_${designer.userId }">
        	<div class="item-gallery">
        	</div>
            <div class="fourpic-text">${designer.favorite }</div>
        </div>
        	<a href="seller/sellerHome?sellerId=${designer.userId }" title="CLICK HERE TO SEE HER HOME PAGE" target="_blank">
				<c:choose>
	            <c:when test="${empty designer.sellerFileId }">
	            <img class="independentBrandPortrait" src="static/images/global/blank.png" />
	            </c:when><c:otherwise>
	            <img class="independentBrandPortrait" src="${fileServerBasePath }image/resize/${designer.sellerFileId }?width=170&height=170" />
	            </c:otherwise></c:choose>
			</a>
          <div class="independentShopName">${mfn:upperCase(designer.storeName) } &nbsp;&nbsp;<span>${designer.countryName }</span></div>
          <div class="brandItemsCount">
              <span class="left">${designer.itemCount }</span>
              <p class="left">ITEMS 商品</p>
          </div>
          <div><a href="javascript:void(0)" onclick="shopFavorite(this,'${designer.userId}')" class="brandFavoriteBtn ${designer.userId}"></a></div>
          <div><a href="javascript:void(0)" onclick="showShopLastItems(this,'${designer.userId}')" class="brandAddBtn"></a></div>
        </li>
        </c:if>
        </c:forEach>
       </ul>
      	<!-- 提示框 -->
		<div id="searchwarning" class="warningdialog">
		  <p>WARNING 提醒<a href="javascript:void(0)" onclick="$('#searchwarning').hide();"></a></p>
		  <div class="warningdialogcontent">
		      SORRY,NO FOUND.<br>暂无搜到您想要的结果。<br>
		      <input type="button" value="确定 YES" onclick="$('#searchwarning').hide();">
		  </div>
		</div>
		<!-- 提示框    结束-->
      </div>
      <div class="clearfix"></div>
      <!-- brand页码 -->
      <div class="pagination-simple">
			<pagination:pagenav pageInfo="${pageInfo }" url="${actionPath }" formName="submitForm" gotoFunction="switchPage" className="pagination-prev"></pagination:pagenav>
		</div>
      <!-- brand页码 结束 -->
  </div>
</div>
<!-- INDEPENDENT BRAND内容结束 -->

<script type="text/javascript" src="static/javascript/page/shops.js"></script>

<form id="requestForm"></form>
<%@include file="/views/global/scripts.jsp" %>
<%@include file="/views/global/footer.jsp" %>
<script type="text/javascript">
$(document).ready(function(){
	<c:if test="${empty entityList }">$("#searchwarning").show();</c:if>
	<c:if test="${not empty searchVo.categoryIdPath }">
		$(".brandNavLeft").children().removeClass("brandTriCategoryactive");
		$(".brandNavLeft").find("li[idpath='${searchVo.categoryIdPath}']").addClass("brandTriCategoryactive");
	</c:if>
});

function showShopLastItems(target, sellerId){
	var dest = $('#seller_'+sellerId);
	$(dest).toggle();
	$(target).toggleClass("brandAddBtn2");
	$.getEx("seller/shops/getLastItems", 
			{sellerId: sellerId}, 
	function(jsonData){
		var strArray = new Array();
		if(true == jsonData.success){
			for(var i=0; i< jsonData.itemList.length; i++){
				var itemInfo = jsonData.itemList[i];
				strArray.push('<div class="fourpic">');
				var fileId = itemInfo.mainUrl.substr(9);
				strArray.push('<a target="_blank" href="item/detail?id='+itemInfo.id+'"><img src="${fileServerBasePath}image/resize/'+fileId+'?width=100&height=100" width="104" height="104"/></a>');
				strArray.push('</div>');
			}
		}
		$(".item-gallery", dest).html(strArray.join(""));
	}, "json");
}

function shopFavorite(target, sellerId){
	$("#requestForm").goAjax({
		url:"seller/statistics/like",
		type: "POST",
		semantic:false,
		checkLogin: true,
		dataType: "json",
		data:{sellerId: sellerId},
		success:function(jsonData){
		  if(false == jsonData.success){
				$.error(jsonData.message);
		  } else {
			if(jsonData.message=="-1"){
				var left = parseInt($(target).offset().left)+10, top =  parseInt($(target).offset().top)-10, obj=$("target");
			     $(target).append('<div id="zhan"><b>-1<\/b></\div>');
			     $('#zhan').css({'position':'absolute','z-index':'1', 'color':'#C30','left':left+'px','top':top+'px'}).animate({top:top-10,left:left+10},'slow',function(){
			          $(this).fadeIn('fast').remove();
			     });
			     $(target).css("background-image","url(static/images/page/independentBrand/brandFavorite.png)");
			}else if(jsonData.message=="1"){
				var left = parseInt($(target).offset().left)+10, top =  parseInt($(target).offset().top)-10, obj=$(".favoriteBtn");
			     $(target).append('<div id="zhan"><b>+1<\/b></\div>');
			     $('#zhan').css({'position':'absolute','z-index':'1', 'color':'#C30','left':left+'px','top':top+'px'}).animate({top:top-10,left:left+10},'slow',function(){
			          $(this).fadeIn('fast').remove();
			     });
			     $(target).css("background-image","url(static/images/page/independentBrand/brandFavorite2.png)");
			}
			//$.message("OPERATION SUCCESSFUL! ", {time: 2});
			//$(target).removeClass("brandFavoriteBtn").addClass("brandFavoriteBtn2");
		}
	 }
	});
}
</script>
</body>
</html>
